home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 466_01 / SRC / FMTINDEX.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-20  |  2.1 KB  |  110 lines

  1. #include <afx.h>
  2. #include <afxtempl.h>
  3. #include "parse.h"
  4. #include "input.h"
  5. #include "fmt.h"
  6. #include "fmtindex.h"
  7. #include "errmsg.h"
  8.  
  9.  
  10. /******************************************************/
  11. // Tag list
  12. /******************************************************/
  13.  
  14. TAGSPEC gtagsIndexSection[] =
  15. {
  16.     CFmtListIndex::tagPre,              "pre",
  17.     CFmtListIndex::tagPost,             "post",
  18.     CFmtListIndex::tagPreName,          "prename",
  19.     CFmtListIndex::tagPostName,         "postname",
  20.     CFmtListIndex::tagPreContext,       "precontext",
  21.     CFmtListIndex::tagPostContext,      "postcontext",
  22.     CFmtListIndex::tagFormat,           "format",
  23.     CFmtListIndex::tagOutput,           "output",
  24.     -1,        NULL,
  25. };
  26.  
  27.  
  28. /******************************************************/
  29. // Format class
  30. /******************************************************/
  31.  
  32. CFmtIndex::CFmtIndex(void) : CFmtBase(7)
  33. {
  34. }
  35.  
  36.  
  37. /******************************************************/
  38. // List class
  39. /******************************************************/
  40.  
  41.  
  42. TAGSPEC *CFmtListIndex::FmtTagList(void)
  43. {
  44.     return gtagsIndexSection;
  45. }
  46.     
  47.  
  48. int CFmtListIndex::ParseEntry(CFmtInput &in)
  49. {
  50.     int nRet;
  51.  
  52.     CFmtIndex *pNew;
  53.  
  54.     pNew = (CFmtIndex *)m_pNew;
  55.  
  56.     switch(m_nTag)
  57.     {
  58.     // Parent
  59.  
  60.     case tagOutput:
  61.         
  62.         // Expect: .output = output
  63.  
  64.         if(in.m_nTokens != 1)
  65.             return fmterrBadEntryCount;
  66.  
  67.         if(!CheckOutputType(in, 0))
  68.             return 0;
  69.  
  70.         nRet = CheckAddTag();
  71.         if(nRet)
  72.             return nRet;
  73.  
  74.         // Make a new one
  75.  
  76.         m_pNew = pNew = new CFmtIndex;
  77.  
  78.         m_nState.Tag = TRUE;
  79.  
  80.         // Record source file information.
  81.  
  82.         pNew->SetSource(in.m_nFile, in.m_lCurLine);
  83.  
  84.         break;
  85.  
  86.     case tagPreName:
  87.     case tagPostName:
  88.     case tagPreContext:
  89.     case tagPostContext:
  90.         return fmterrObsoleteIndexFormatString;
  91.  
  92.     case tagPre:
  93.     case tagPost:
  94.     case tagFormat:
  95.         // expect: .pre= format string
  96.  
  97.         nRet = SetFmtString(in, 0);
  98.  
  99.         if(nRet)
  100.             return nRet;
  101.         break;
  102.  
  103.     default:
  104.         return fmterrBadFmtEntry;
  105.     }
  106.  
  107.     return 0;
  108. }
  109.  
  110.